import java.util.Random;
import java.util.Scanner;

public class Main {


    public static void main5(String[] args) {
        // 字符串转换为整形
        String a = "123";
        int aa = Integer.valueOf(a);
        System.out.println(aa+1);
    }
    //整形转换为字符串
    public static void main4(String[] args) {

        int a = 10;
        String ret = String.valueOf(a);
        System.out.println(ret);
        double b = 11.22;
        String rot = String.valueOf(b);
        System.out.println(rot);
    }
    public static void main1(String[] args) {
        System.out.println("美丽人生");
    }

    public static void main2(String[] args) {
        String str1 = "oho";
        String str2 = "nice";
        int a = 20;
        int b = 30;
        System.out.println(str1 + str2);
        System.out.println(str1 + " " + str2);
        System.out.println(a+b);
        System.out.println(b + str2);
        System.out.println(str1 +"="+ (a + b));
    }

    public static void main3(String[] args) {
        String str1 = "oho";
        String str2 = "nice";
        int a = 20;
        int b = 30;
        System.out.println(str1 +"="+ (a + b));
    }
//    //switch的练习
//    。
//    。
//       不能做switch的数据类型有四种： long float double boolean
    //   可以的有： byte short int char string
//    。
    public static void main6(String[] args) {
    int a =2;
    switch(a){
        case 1:
            System.out.println("cyh666");
            break;
        case 2:
            System.out.println("yyt666");
            break;
        default:
            System.out.println("输入错误");
            break;
        }
    }

    public static void main7(String[] args) {
        int a = 1;
        while(a <= 5){
            System.out.println(a);
            ++a;
        }
    }

    public static void main8(String[] args) {
        int a = 1;
        int sum = 0;
        while(a <= 100){
            sum = sum + a;
            a++;
        }
        System.out.println(sum);
    }

    public static void main9(String[] args) {
        int a = 0;
        while(a <= 100){
            a++;
            if(a % 3 == 0 && a % 5 == 0){
                System.out.println(a );
                continue;
            }
        }
    }
//      用循环结构实现阶乘的和运算
//      1!+2!+3!+4!+5! 的和

    public static void main10(String[] args) {
        int sum = 0;

        for (int i = 1; i <= 5; i++) {
            int trp = 1;
            for (int j = 1; j <= i; j++) {
                 trp = trp * j;
            }
            sum += trp;
        }
        System.out.println(sum);
    }

    public static void main11(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入姓名");
        String name = scan.nextLine();
        System.out.println("请输入年龄");
        int age = scan.nextInt();
        System.out.println("请输入收入");
        float income = scan.nextFloat();
        System.out.println("你的信息如下： ");
        System.out.println(name + "  " + age +"  " + income );


    }


    //   ==================
    //
    //   循环输入数据
    //   ==================
    //
    public static void main12(String[] args) {
        Scanner scan = new Scanner(System.in);
        while(scan.hasNextInt()){
            int n = scan.nextInt();
            System.out.println("n = " + n);
        }
    }

    // ============
    // ============
    //  做一个猜数字游戏   0到100
    // ============
    // ============
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        Random random = new Random();
        //生成 0 到 100 之间的随机数
        int randnumber = random.nextInt(100);
        //  显示 所生成的随机数
        //System.out.println(randnumber);
        while(true){
            System.out.println("请输入 你要猜的数字");
            int num = scan.nextInt();
            if(num > randnumber){
                System.out.println("猜大了");
            }else if(num < randnumber){
                System.out.println("猜小了");
            }else{
                System.out.println("猜对了 !!!");
                break;
            }

        }

    }

}



















